/**
 * Created by zhangqingxi on 2017-05-08.
 */


/**
 * 加载表格
 *
 */
function  loadDataList() {

    $('#dataList').datagrid({
        url:modelPath+'findByParam.shtml',
        queryParams:{
            sort:'d.addTime',
            order:'desc'
        },
        // idField:'id',
        fitColumns:true,
        pagination:true,
        rownumbers:true,
        singleSelect:true,
        sortOrder:true,
        striped:true,
        fit:true,
        columns:[[
            {field:'id',width:10,checkbox:true},

            {field:'userName',title:'监测人员名称',width:10},
            {field:'responsibilities',title:'职责说明',width:10},
            {field:'yearOfWork',title:'相关工作年限',width:10},

            {field:'addUserName',title:'登记人',width:10},
            {field:'addDeptName',title:'登记部门',width:10},
            {field:'d.addTime',title:'登记时间',width:10,sortable:true,formatter:function (value,row,index) {
                return row.addTime;
            }}
        ]],
        toolbar: '#toolbar'

    });


}




$(function () {
    loadDataList();

    //高级查询
    initAdvancedSearch();

    //查询按钮事件
    initSearchClick();

    //重置参数
    initResetClick();

    //添加按钮事件
    $('#btn_monitor_personnel_add').on('click',function () {

        openLayer("添加监测人员",modelPath+"add.shtml",['600px', '380px']);

    });
    //编辑按钮事件
    $('#btn_monitor_personnel_edit').on('click',function () {

        var checkedRows=$('#dataList').datagrid('getChecked');
        if(checkedRows.length === 0){
            layer.alert("选择需要修改的行！");
            return
        }
        var id=checkedRows[0].id;

        openLayer("编辑监测人员",modelPath+"edit.shtml?id="+id,['600px', '380px']);
    });

    //删除按钮事件
    $('#btn_monitor_personnel_delete').on('click',function () {

        var checkedRows=$('#dataList').datagrid('getChecked');
        if(checkedRows.length === 0){
            layer.alert("选择需要删除的行！");
            return
        }

        var id=checkedRows[0].id;
        initDeleteClick(modelPath,id);

    });

});
